package demo1;

/**
 * @Author 12629
 * @Description：
 */
public class Test {

    public static void eatFunc(Animal animal) {
        animal.eat();
    }

    public static void main(String[] args) {

        Bird bird = new Bird("愤怒的小鸟",10);

        Dog dog = new Dog("旺财",10);

        eatFunc(bird);

        System.out.println("===========");

        eatFunc(dog);
    }



    public static void main5(String[] args) {
        Animal animal = new Bird("愤怒的小鸟",10);
        Bird bird = (Bird)animal;
        bird.fly();

        System.out.println("=======");

        Animal animal2 = new Dog("旺财",10);

        if(animal2 instanceof Bird) {
            Bird bird2 = (Bird) animal2;
            bird2.fly();
            System.out.println("animal2 instanceof Bird");
        }else {
            System.out.println("! animal2 instanceof Bird");
        }


    }




















    public static int add(int a,int b) {
        return a+b;
    }

    public static int add(int a,int b,int c) {
        return a + b + c;
    }

    public static void main4(String[] args) {
        System.out.println(add(1, 2));
        System.out.println(add(1, 2,3));
    }

    public static void main3(String[] args) {
        Animal animal = new Dog("旺财",10);

        animal.eat();

        animal.func();

        //animal.bark();
    }

    public static void main2(String[] args) {
        /*Dog dog = new Dog("旺财",10);
        dog.eat();*/


        Animal animal = new Dog("旺财",10);

        animal.eat();
        //animal.bark();

        Dog dog = new Dog("旺财",10);
        System.out.println(dog);

    }
    public static void main1(String[] args) {

        /*Animal animal = new Animal("fafa",10);

        Dog dog = new Dog("旺财",10);


        animal = dog;*/

        //Animal animal = new Dog("旺财",10);

        Dog dog = new Dog("旺财",10);

        test1(dog);

    }

    public Animal test2() {
        return new  Dog("旺财",10);
    }

    public Animal test3() {
        return new Cat("旺财",10);
    }

    public static void test1(Animal animal) {

    }
}
